import 'package:distribution_mall_flutter/generated/json/base/json_convert_content.dart';
import 'package:distribution_mall_flutter/entity/user/user_distributor_info_entity.dart';

UserDistributorInfoBody $UserDistributorInfoBodyFromJson(
    Map<String, dynamic> json) {
  final UserDistributorInfoBody userDistributorInfoBody = UserDistributorInfoBody();
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    userDistributorInfoBody.name = name;
  }
  final String? address = jsonConvert.convert<String>(json['address']);
  if (address != null) {
    userDistributorInfoBody.address = address;
  }
  final List<dynamic>? qualifications = (json['qualifications'] as List<
      dynamic>?)?.map(
          (e) => e).toList();
  if (qualifications != null) {
    userDistributorInfoBody.qualifications = qualifications;
  }
  final String? status = jsonConvert.convert<String>(json['status']);
  if (status != null) {
    userDistributorInfoBody.status = status;
  }
  final String? merchantType = jsonConvert.convert<String>(
      json['merchantType']);
  if (merchantType != null) {
    userDistributorInfoBody.merchantType = merchantType;
  }
  final UserDistributorInfoBodyLevel? level = jsonConvert.convert<
      UserDistributorInfoBodyLevel>(json['level']);
  if (level != null) {
    userDistributorInfoBody.level = level;
  }
  final bool? hasCertified = jsonConvert.convert<bool>(json['hasCertified']);
  if (hasCertified != null) {
    userDistributorInfoBody.hasCertified = hasCertified;
  }
  final String? parentInvitationCode = jsonConvert.convert<String>(
      json['parentInvitationCode']);
  if (parentInvitationCode != null) {
    userDistributorInfoBody.parentInvitationCode = parentInvitationCode;
  }
  return userDistributorInfoBody;
}

Map<String, dynamic> $UserDistributorInfoBodyToJson(
    UserDistributorInfoBody entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['name'] = entity.name;
  data['address'] = entity.address;
  data['qualifications'] = entity.qualifications;
  data['status'] = entity.status;
  data['merchantType'] = entity.merchantType;
  data['level'] = entity.level?.toJson();
  data['hasCertified'] = entity.hasCertified;
  data['parentInvitationCode'] = entity.parentInvitationCode;
  return data;
}

extension UserDistributorInfoBodyExtension on UserDistributorInfoBody {
  UserDistributorInfoBody copyWith({
    String? name,
    String? address,
    List<dynamic>? qualifications,
    String? status,
    String? merchantType,
    UserDistributorInfoBodyLevel? level,
    bool? hasCertified,
    String? parentInvitationCode,
  }) {
    return UserDistributorInfoBody()
      ..name = name ?? this.name
      ..address = address ?? this.address
      ..qualifications = qualifications ?? this.qualifications
      ..status = status ?? this.status
      ..merchantType = merchantType ?? this.merchantType
      ..level = level ?? this.level
      ..hasCertified = hasCertified ?? this.hasCertified
      ..parentInvitationCode = parentInvitationCode ??
          this.parentInvitationCode;
  }
}

UserDistributorInfoBodyLevel $UserDistributorInfoBodyLevelFromJson(
    Map<String, dynamic> json) {
  final UserDistributorInfoBodyLevel userDistributorInfoBodyLevel = UserDistributorInfoBodyLevel();
  final String? levelName = jsonConvert.convert<String>(json['levelName']);
  if (levelName != null) {
    userDistributorInfoBodyLevel.levelName = levelName;
  }
  return userDistributorInfoBodyLevel;
}

Map<String, dynamic> $UserDistributorInfoBodyLevelToJson(
    UserDistributorInfoBodyLevel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['levelName'] = entity.levelName;
  return data;
}

extension UserDistributorInfoBodyLevelExtension on UserDistributorInfoBodyLevel {
  UserDistributorInfoBodyLevel copyWith({
    String? levelName,
  }) {
    return UserDistributorInfoBodyLevel()
      ..levelName = levelName ?? this.levelName;
  }
}